<script>

export default {
    render: function (createElement) {
        return createElement("div", {
            attrs: {
                id: "MutiChart",
            },
            style: {
                height: "100%"
            }
        });
    },
    data() {

    },
    methods: {
        initEchart() {
            var chartDom = document.getElementById('MutiChart');
            var myChart = echarts.init(chartDom);

            var option = {
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'cross',
                        crossStyle: {
                            color: '#999'
                        }
                    }
                },
                toolbox: {
                    feature: {
                        dataView: { show: true, readOnly: false },
                        magicType: { show: true, type: ['line', 'bar'] },
                        restore: { show: true },
                        saveAsImage: { show: true }
                    }
                },
                legend: {
                    data: ['Evaporation', 'Precipitation', 'Temperature']
                },
                xAxis: [
                    {
                        type: 'category',
                        // 年份坐标
                        data: ['2014', '2015', '2016', '2017', '2018', '2019', '2020', '2021', '2022', '2023',],
                        axisPointer: {
                            type: 'shadow'
                        }
                    }
                ],
                yAxis: [
                    {
                        type: 'value',
                        name: '软件业务收入',
                        min: 0,
                        max: 120000,
                        interval: 30000,
                        axisLabel: {
                            textStyle: { fontSize: 7 },
                            formatter: '{value} '
                        }
                    },
                    {
                        type: 'value',
                        name: '同比增长',
                        min: 0,
                        max: 25,
                        interval: 5,
                        axisLabel: {
                            formatter: '{value} %'
                        }
                    }
                ],
                series: [
                    {
                        name: '软件业务收入（亿元）',
                        type: 'bar',
                        tooltip: {
                            valueFormatter: function (value) {
                                return value + ' 亿元';
                            }
                        },
                        // 软件业务收入 / 亿元
                        data: [
                            '37026', '42848', '48232', '55103', '61909', '72072', '81566', '95502', '106126', '123258'
                        ]
                    },
                    {
                        name: '同比增长',
                        type: 'line',
                        yAxisIndex: 1,
                        tooltip: {
                            valueFormatter: function (value) {
                                return value + ' %';
                            }
                        },
                        data: [
                            21.1, 15.7, 12.6, 14.2, 12.4, 16.4, 13.2, 17.1, 11.2, 13.4
                        ]
                    }
                ]
            };

            myChart.setOption(option);
        }
    },
    mounted() {
        this.initEchart();
    }
};
</script>